<script type="text/javascript">
$(function(){
	if($('.txt_highlight').is(':visible')){
		$('.txt_highlight').delay(2000).fadeOut();
		}
	
})
function update_address()
{
	var $com_id = $('#com').val();
	var $house_num= $('.adresse_item input[name$="house_num"]').val();
	var $address= $('.adresse_item input[name$="address"]').val();
	var $ring = $('.adresse_item input[name$="ring"]').val();
	var $tele = $('.adresse_item input[name$="tele"]').val();
	var $com_arrow = $('#com_arrow');
	var $address_arrow = $('#address_arrow');
	var $ring_arrow = $('#ring_arrow');
	var $tele_arrow = $('#tele_arrow');
	if($com_id !='null'  && $house_num !='' && $address !='' && $ring !='' && $tele !=''){
		$('#update_address').submit();
	}else{
		if($com_id == 'null'){$com_arrow.show();}else{$com_arrow.hide();}
		if($house_num =='' || $address ==''){$address_arrow.show();}else{$address_arrow.hide();}
		if($tele ==''){$tele_arrow.show();}else{$tele_arrow.hide();}
		if($ring ==''){$ring_arrow.show();}else{$ring_arrow.hide();}
	}
}
</script>
<div id="container">
	<div id="sidebar">
		<div class="logo">
			<a href="<?=site_url()?>"><img
				src="<?=base_url()?>resources/imgs/logo.png" alt="" width="200"> </a>
			<p class="sub-title">Traiteur Chinois</p>
		</div>
		<div class="submenu">
			<h3>
				<a href="<?=site_url('account')?>">Vos Commandes</a>
			</h3>
			<br>
			<h3>
				<a href="<?=site_url('account/address')?>">Adresses Livraisons</a>
			</h3>
			<br>
			<h3>
				<a href="<?=site_url('account/update_password')?>">Mot de Passe</a>
			</h3>
			<br>
			<hr>
		</div>
		<h3>
			<img src="<?=base_url()?>/resources/imgs/cart.png" alt="Panier"
				title="Panier" height="16"> Panier
				<?=$this->cart->total_items()?>
			|
			<?=number_format($this->cart->total(),2,'.','')?>
			€
		</h3>

		<?php $i = 1; ?>
		<?php if(!$this->cart->contents()){?>
		<p>Panier Vide</p>
		<?php }?>

		<?php foreach ($this->cart->contents() as $items): ?>
		<div class="order_item">
			<span class="product_item"> <?=$items['product_num']?>.<?=nbs(0)?> <?php echo $items['name']; ?>
			</span> <span class="qty"><?php if($items['options_price'] !=NULL && $items['options_price'] != 0){?>
			<?=number_format($items['price']+$items['options_price'],2,'.','')?>
				€ (<?=$items['qty']?>)<?php }else{?> <?=number_format($items['price'],2,'.','')?>
				€ (<?=$items['qty']?>)<?php }?> </span> <br> <span class="option"><?php if($this->cart->has_options($items['rowid'])==TRUE):?><label><small>OPTIONs:
				</small> </label> <?php foreach ($this->cart->product_options($items['rowid']) as $option): ?>
				<?=nbs(1)?> <small><?php echo $option['option_name']; ?> <?php if( $option['price'] !=NULL ){ echo ': '.$option['price'].' €';} ?>
			</small> <?=nbs(1)?> <?php endforeach; ?> <?php endif; ?> </span>
			<div class="clear"></div>

		</div>
		<?php $i++; ?>
		<?php endforeach; ?>
		<div class="clear"></div>
		<br> <br> 
		<input class="btn_panier" type="button" value="MON PANIER" onclick="document.location.href='<?=site_url('cart')?>'">
		<hr>
	<?php if($this->discount || $this->discount_delivery){?>
		<h3>Promo!</h3>
		<?php if($this->discount){?>
	<div class="promo">
	A partir du <?=date('d M. Y',strtotime($this->discount[0]->discount_start))?> jusqu'au <?=date('d M. Y',strtotime($this->discount[0]->discount_end))?>, Une Réduction de <?=$this->discount[0]->discount_val*100?>% pour toutes les commandes paiement par espèces !!!
	</div>
	<?php }?>
	<?php if($this->discount_delivery){?>
	<div class="promo">
	A partir du <?=date('d M. Y',strtotime($this->discount_delivery[0]->discount_start))?> jusqu'au <?=date('d M. Y',strtotime($this->discount_delivery[0]->discount_end))?>,  Pour les commandes de livraison, Une Réduction de <?=$this->discount_delivery[0]->discount_val*100?>% 
	pour les communes: <br>
	<?php foreach ($this->discount_delivery[0]->community as $c):?>
	<?=$c->code?> <?=$c->name?> / 
	<?php endforeach;?>
	!!!</div>
	<?php }?>
	<?php }?>
	
		
	

	</div>
	<div class="rightbar">
		<div class="ctn_account">

			<div class="delivery_address">
				<h4>Votre Adresse de Livraison</h4>

				<div class="adresse_item">
					<hr>
					<?php if($delivery_adresse ==false){?>
					<h4 class="error">Aucune adresse de livraison a été enregistré.</h4>
					<form action="" method="post" id="update_address">
						<label>Code Postal - Commune</label>
						<div class="com-select">

							<select name="com" id="com">
								<option value="null" limit="null">choisissez votre commune...</option>
								<?php foreach ($coms as $c):?>
								<option value="<?=$c->id?>" com_code="<?=$c->code?>">
								<?=$c->code?>
									|
									<?=$c->name?>
								</option>
								<?php endforeach;?>
							</select>
						</div>
						<img class="date_arrow" id="com_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25">
						<div class="clear"></div>
						<label>Numéro - Adresse</label><span><input name="house_num"
							value="" type="text" style="width: 50px;"> - <input
							name="address" value="" type="text"> </span><img
							class="date_arrow" id="address_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <label>Sonnette:</label><span><input
							name="ring" value="" type="text"> </span><img class="date_arrow"
							id="ring_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <label>Société ( option )</label><span><input
							name="company" value="" type="text"> </span> <label>Téléphone:</label>
						<span> <input name="tele" value="" type="text"> </span><img
							class="date_arrow" id="tele_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <br>&nbsp;( example:
						0484000000 )
						<hr>
						<input value="sauvegarder" type="button"
							onclick="update_address();">&nbsp;&nbsp;
					</form>
					<?php }else{ ?>
					<form action="" method="post" id="update_address">
						<label>Code Postal - Commune</label>
						<div class="com-select">

							<select name="com" id="com">
								<option value="null" limit="null">choisissez votre commune...</option>
								<?php foreach ($coms as $c):?>
								<option value="<?=$c->id?>" com_code="<?=$c->code?>"
								<?php if($delivery_adresse->postal == $c->code){echo  'selected = "selected"';}?>>
									<?=$c->code?>
									|
									<?=$c->name?>
								</option>
								<?php endforeach;?>
							</select>
						</div>
						<img class="date_arrow" id="com_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25">
						<div class="clear"></div>
						<label>Numéro - Adresse</label><span><input name="house_num"
							value="<?=$delivery_adresse->house_num?>" type="text"
							style="width: 50px;"> - <input name="address"
							value="<?=$delivery_adresse->address?>" type="text"> </span><img
							class="date_arrow" id="address_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <label>Sonnette:</label><span><input
							name="ring" value="<?=$delivery_adresse->ring?>" type="text"> </span><img
							class="date_arrow" id="ring_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <label>Société ( option )</label><span><input
							name="company" value="<?=$delivery_adresse->company?>"
							type="text"> </span> <label>Téléphone:</label> <span> <input
							name="tele" value="<?=$delivery_adresse->tele?>" type="text"> </span><img
							class="date_arrow" id="tele_arrow"
							src="<?=base_url()?>resources/imgs/arrow_back_red.png"
							alt="arrow" title="arrow" width="25"> <br>&nbsp;( example:
						0484000000 )
						<hr>
						<input value="modifier" type="button" onclick="update_address();">&nbsp;&nbsp;
					</form>
					<?php }?>
					<?=isset($msg) ? '<span class="txt_highlight">'.$msg.'</span>' :''?>
					<div class="clear"></div>
				</div>



			</div>
			<div class="clear"></div>
		</div>
	</div>
	<div class="clear"></div>
</div>

